<?php
 /**
 * ECSHOP 微信扫码支付回调页面
 * ============================================================================
 * $Author: 凡人 QQ：644157559 $
 */
define('IN_ECS', true);
require(str_replace("/wxpay", '', dirname(__FILE__)) . '/includes/init.php');
$user_id = $_SESSION['user_id'];
$log_id = intval($_POST['id']);
if (!empty($user_id) && !empty($log_id)) {
    $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('pay_log') . " WHERE log_id = '$log_id'";
    $pay_log = $GLOBALS['db']->getRow($sql);
    if ($pay_log && $pay_log['is_paid'] == 1){
        if ($pay_log['order_type'] == PAY_ORDER) {
            exit(json_encode(array('status' => 1, 'type' => 0, 'url' => "user.php?act=order_detail&order_id={$pay_log["order_id"]}", 'order_id' => $pay_log["order_id"])));
        }else if($pay_log['order_type'] == PAY_SURPLUS) {
            exit(json_encode(array('status' => 1, 'type' => 1, "url" => 'user.php?act=account_log')));
        }
    }
}
exit(json_encode(array('status' => 0)));